<?php
include_once 'security/token.php';
include $_SERVER['DOCUMENT_ROOT']."/lib/spyc.php";
$ENV = spyc_load_file($_SERVER['DOCUMENT_ROOT'].'/properties/env.yml');
$host = ($ENV['upload']['host'])['0'];

$tokenInstance = new Token();
$tokenInstance->clean();      // 首先清除数据库中的无效token
@$token = $_COOKIE['token'];
if ($token) {
    if (!($tokenInstance->verify($token))) {
        $tokenCreate = $tokenInstance->create();
        setcookie('token', $tokenCreate, time()+24*60*60, '/', $host, false, true);
    }
} else {
    $tokenCreate = $tokenInstance->create();
    setcookie('token', $tokenCreate, time()+24*60*60, '/', $host, false, true);
}


header("location:http://$host:92/upload.html");
exit();
